<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    /* 大盒子居中 */
    .carousel {
      position: relative;
      width: 800px;
      height: 500px;
      border: 1px solid #000;
      margin: 100px auto;
      overflow: hidden;
    }
    /* 所有的图片，水平排列 */
    .pic {
      position: absolute;
      /* 考虑到子元素有可能增加，为了避免有的子元素掉下去 */
      width: 5000px;
      height: 500px;
      top: 0;
      left: 0;
      /* 过渡动画 */
      transition: all 2s ease;
    }

    .pic img {
      float: left;
    }
    /* 通过不同的表单被选中的状态，控制后面 pic 的样式 */
    .carousel .check1:checked ~ .pic {
      left: 0;
    }
    .carousel .check2:checked ~ .pic {
      left: -800px;
    }
    .carousel .check3:checked ~ .pic {
      left: -1600px;
    }
    .carousel .check4:checked ~ .pic {
      left: -2400px;
    }

    /* 按钮样式 */
    .btn {
      position: absolute;
      left: 100px;
      bottom: 50px;
    }
    .btn label {
      float: left;
      width: 20px;
      height: 20px;
      margin-right: 20px;
      background-color: #fff;
      cursor: pointer;
    }
  </style>
</head>
<body>
  <div class="carousel">
    <!-- 在图片前面添加一组单选框 -->
    <input type="radio" class="check1" name="button" checked="checked" id="btn1">
    <input type="radio" class="check2" name="button" id="btn2">
    <input type="radio" class="check3" name="button" id="btn3">
    <input type="radio" class="check4" name="button" id="btn4">
    <div class="pic">
      <img src="images/01.jpg" alt="">
      <img src="images/02.jpg" alt="">
      <img src="images/03.jpg" alt="">
      <img src="images/04.jpg" alt="">
    </div>
    <!-- 添加一些绑定表单的元素 -->
    <div class="btn">
      <label for="btn1"></label>
    <label for="btn2"></label>
    <label for="btn3"></label>
    <label for="btn4"></label>
    </div>
  </div>
</body>
</html>